/*
 * @Description: 
 * @Author: zoe
 * @Date: 2024-09-25 15:13:25
 * @LastEditors: rendc
 * @LastEditTime: 2024-09-25 16:36:22
 */
public class Student {
    private String name;
    private int age;
    public Student(){
        
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }
    public void setAge(int age){
        this.age = age;
    }
    @Override
    public boolean equals(Object obj){
        System.out.println("重写equal方法");
        //重写equal方法
        boolean result = false;
        if(!(obj instanceof Student)){
            return false;
        }
        //引用地址相同
        if(this == obj){
            System.out.println("引用地址相同");
            return true;
        }
        //第二步判断 判断值是否相同
        //向下转型 强转
        Student stu = (Student)obj;
        if(name.equals(stu.getName()) && age == stu.getAge()){
            System.out.println("值相同");
            result = true;
        }
        return result;
    }
}
